package com.codepoem.designpattern.simplefactory

/**
 * 简单工厂测试类
 */
fun main(args: Array<String>) {
    var oper: Operation
    var result: Double
    //测试加法运算
    oper = OperationFactory.createOperation("+")
    oper.numberA = 1.0
    oper.numberB = 2.0
    result = oper.getResult()
    println(result)
    //测试减法运算
    oper = OperationFactory.createOperation("-")
    oper.numberA = 1.0
    oper.numberB = 2.0
    result = oper.getResult()
    println(result)
    //测试乘法运算
    oper = OperationFactory.createOperation("*")
    oper.numberA = 1.0
    oper.numberB = 2.0
    result = oper.getResult()
    println(result)
    //测试除法运算
    oper = OperationFactory.createOperation("/")
    oper.numberA = 1.0
    oper.numberB = 2.0
    result = oper.getResult()
    println(result)
    //测试除法运算(除数为0)
    oper = OperationFactory.createOperation("/")
    oper.numberA = 1.0
    oper.numberB = 0.0
    result = oper.getResult()
    println(result)
}

